/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Table;

import Model.Pasien;
import java.util.ArrayList;
import java.util.List;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author BIMO
 */
public class TablePasien extends AbstractTableModel {

    private List<Pasien> kategoris = new ArrayList<Pasien>();

    public TablePasien(List<Pasien> kategoris) {
        this.kategoris = kategoris;
    }

    public void deleteKategori(int row) {
        kategoris.remove(row);
        fireTableRowsDeleted(row, row);
    }

    public void updateKategori(int row, Pasien kategori) {
        kategoris.set(row, kategori);
        fireTableRowsUpdated(row, row);
    }

    public void addKategori(Pasien kategori) {
        kategoris.add(kategori);
        fireTableRowsInserted(getRowCount() - 1, getColumnCount() - 1);
    }

    public int getRowCount() {
        return kategoris.size();
    }

    public int getColumnCount() {
        return 2;
    }

    public Object getValueAt(int rowIndex, int columnIndex) {
        Pasien b = kategoris.get(rowIndex);
        switch (columnIndex) {

            case 0:
                return b.getNoIndex();
            case 1:
                return b.getNamaPasien();

            default:
                return "";
        }
    }

    @Override
    public String getColumnName(int column) {
        switch (column) {

            case 0:
                return "No Index";
            case 1:
                return "Nama Pasien";
            default:
                return "";
        }
    }
}
